home *** CD-ROM | disk | FTP | other *** search
/ BMUG Revelations / BMUG Revelations.toast / Programming / Programming Languages / Harvest C / MPW Int & Lib / Interfaces / Terminals.h < prev    next >
Text File  |  1991-04-17  |  7KB  |  264 lines

  1. /*
  2.     File:        Terminals.h
  3.  
  4.     Contains:    C Interface to the Terminal Manager
  5.  
  6.     Copyright:    © 1988-1990 by Apple Computer, Inc.
  7.                 All rights reserved.
  8.  
  9. */
  10.  
  11.  
  12. #ifndef __TERMINALS__
  13. #define __TERMINALS__
  14.  
  15. #ifndef __DIALOGS__
  16. #include <Dialogs.h>
  17. #endif    __DIALOGS__
  18.  
  19. #ifndef __CTBUTILITIES__
  20. #include <CTBUtilities.h>
  21. #endif    __CTBUTILITIES__
  22.  
  23. #ifndef __CONNECTIONS__
  24. #include <Connections.h>
  25. #endif    __CONNECTIONS__
  26.  
  27. /* current Terminal Manager version     */
  28. #define        curTMVersion    2
  29.  
  30. /* current Terminal Manager Environment Record version     */
  31.  
  32. #define        curTermEnvRecVers    0
  33.  
  34. /* error codes    */
  35. typedef    OSErr TMErr;
  36.  
  37. #define    tmGenericError        (-1)
  38. #define    tmNoErr                0
  39. #define    tmNotSent            1
  40. #define    tmEnvironsChanged    2
  41. #define    tmNotSupported        7
  42. #define    tmNoTools            8
  43.  
  44. /* TMFlags     */
  45. typedef long TMFlags;
  46.  
  47. enum {
  48.     tmInvisible         = 1 << 0,
  49.     tmSaveBeforeClear     = 1 << 1,
  50.     tmNoMenus             = 1 << 2,
  51.     tmAutoScroll         = 1 << 3
  52. };
  53.  
  54. /* TMSelTypes & TMSearchTypes    */
  55. typedef short TMSelTypes;
  56. typedef short TMSearchTypes;
  57.  
  58. enum {
  59.     selTextNormal         = 1 << 0,
  60.     selTextBoxed         = 1 << 1,
  61.     selGraphicsMarquee     = 1 << 2,
  62.     selGraphicsLasso     = 1 << 3,
  63.     
  64.     tmSearchNoDiacrit     = 1 << 8,            /*    These are only for TMSearchTypes    */
  65.     tmSearchNoCase         = 1 << 9
  66. };
  67.  
  68. /*    TMCursorTypes     */
  69. typedef short TMCursorTypes;
  70. enum {
  71.     cursorText = 1,
  72.     cursorGraphics = 2
  73. };
  74.  
  75. /*    TMTermTypes     */
  76. typedef short TMTermTypes;
  77. enum {
  78.     tmTextTerminal         = 1 << 0,
  79.     tmGraphicsTerminal     = 1 << 1
  80. };
  81.  
  82. struct    TermDataBlock {
  83.     TMTermTypes        flags;    
  84.     Handle            theData;
  85.     Handle            auxData;
  86.     long            reserved;
  87. };
  88.  
  89. typedef struct TermDataBlock TermDataBlock;
  90. typedef TermDataBlock *TermDataBlockPtr, **TermDataBlockH;
  91.  
  92. struct TermEnvironRec {
  93.     short            version;
  94.     TMTermTypes        termType;
  95.     short            textRows;
  96.     short            textCols;
  97.     Point            cellSize;
  98.     Rect            graphicSize;
  99.     Point            slop;
  100.     Rect            auxSpace;
  101. };
  102.  
  103. typedef struct TermEnvironRec TermEnvironRec;
  104. typedef TermEnvironRec *TermEnvironPtr;
  105.     
  106. union TMSelection {
  107.     Rect            selRect;
  108.     RgnHandle        selRgnHandle;
  109. };
  110.  
  111. typedef union TMSelection TMSelection;
  112.  
  113. /* TMChoose data structures */
  114. struct TMChooseRec {
  115.     long    reserved;
  116.     long    msg;
  117.     ProcPtr    idleProc;
  118.     ProcPtr    filterProc;
  119.     Str63    newTool;
  120.     Ptr        newConfig;
  121.     ProcPtr    eventProc;
  122. };
  123.  
  124. typedef struct TMChooseRec TMChooseRec;
  125. typedef TMChooseRec *TMChooseRecPtr;
  126.  
  127. /* TMChooseRec messages */
  128. #define    tmChooseNochange        1
  129. #define    tmChooseBackdoor        2
  130.  
  131. struct TermRecord {
  132.         short            procID;
  133.         
  134.         TMFlags            flags;
  135.         TMErr            errCode;
  136.         
  137.         long            refCon;
  138.         long            userData;
  139.         
  140.         ProcPtr            defProc;
  141.         
  142.         Ptr                config;
  143.         Ptr                oldConfig;
  144.         
  145.         ProcPtr            environsProc;
  146.         long            reserved1;
  147.         long            reserved2;
  148.     
  149.         Ptr                tmPrivate;
  150.                         
  151.         ProcPtr            sendProc;
  152.         ProcPtr            breakProc;
  153.         ProcPtr            cacheProc;
  154.         ProcPtr            clikLoop;
  155.         
  156.         WindowPtr        owner;
  157.         Rect            termRect;
  158.         Rect            viewRect;
  159.         Rect            visRect;
  160.         
  161.         long            lastIdle;
  162.         
  163.         TMSelection        selection;
  164.         TMSelTypes        selType;
  165.         
  166.         long            mluField;
  167. };
  168.  
  169. typedef struct TermRecord TermRecord;
  170. typedef TermRecord **TermHandle, *TermPtr;
  171.  
  172. #ifdef __cplusplus
  173. extern "C" {
  174. #endif
  175. pascal TMErr     InitTM(void); 
  176. pascal Handle     TMGetVersion(TermHandle hTerm);
  177. pascal short     TMGetTMVersion(void);
  178.  
  179. pascal TermHandle TMNew(const Rect *termRect, const Rect *viewRect, TMFlags flags, 
  180.                             short procID, WindowPtr owner, ProcPtr sendProc, 
  181.                             ProcPtr cacheProc, ProcPtr breakProc, ProcPtr clikLoop, ProcPtr environsProc,
  182.                             long refCon, long userData);
  183.  
  184. pascal void     TMDispose(TermHandle hTerm);
  185.  
  186. pascal void     TMKey(TermHandle hTerm, const EventRecord *theEvent);
  187. pascal void     TMUpdate(TermHandle hTerm, RgnHandle visRgn);
  188. pascal void     TMPaint(TermHandle hTerm, const TermDataBlock *theTermData, const Rect *theRect);
  189. pascal void     TMActivate(TermHandle hTerm, Boolean activate);
  190. pascal void     TMResume(TermHandle hTerm, Boolean resume);
  191. pascal void     TMClick(TermHandle hTerm, const EventRecord *theEvent);
  192. pascal void     TMIdle(TermHandle hTerm);
  193.  
  194. pascal long     TMStream(TermHandle hTerm, void *theBuffer, long theLength, CMFlags flags);
  195. pascal Boolean     TMMenu(TermHandle hTerm, short menuID, short item);
  196.  
  197. pascal void     TMReset(TermHandle hTerm);
  198. pascal void     TMClear(TermHandle hTerm);
  199.  
  200. pascal void        TMResize(TermHandle hTerm, const Rect *newViewRect);
  201.  
  202. pascal long     TMGetSelect(TermHandle hTerm, Handle theData, ResType *theType);
  203. pascal void     TMGetLine(TermHandle hTerm, short lineNo, TermDataBlock *theTermData);
  204. pascal void     TMSetSelection(TermHandle hTerm, const TMSelection *theSelection, TMSelTypes selType);
  205.  
  206. pascal void     TMScroll(TermHandle hTerm, short dh, short dv);
  207.  
  208.  
  209. pascal Boolean     TMValidate(TermHandle hTerm);
  210. pascal void         TMDefault(Ptr *theConfig, short procID, Boolean allocate);
  211.  
  212. pascal Handle     TMSetupPreflight(short procID, long *magicCookie);
  213. pascal void     TMSetupSetup(short procID, const void *theConfig, short count, DialogPtr theDialog,
  214.                     long *magicCookie);
  215. pascal Boolean     TMSetupFilter(short procID, const void *theConfig, short count, DialogPtr theDialog,
  216.                     EventRecord *theEvent, short *theItem, long *magicCookie);
  217. pascal void     TMSetupItem(short procID, const void *theConfig, short count, DialogPtr theDialog,
  218.                     short *theItem, long *magicCookie);
  219. pascal void     TMSetupCleanup(short procID, const void *theConfig, short count, DialogPtr theDialog,
  220.                     long *magicCookie);
  221. pascal void     TMSetupXCleanup(short procID, const void *theConfig, short count, DialogPtr theDialog,
  222.                     Boolean OKed, long *magicCookie );
  223. pascal void     TMSetupPostflight(short procID);
  224.  
  225. pascal Ptr         TMGetConfig(TermHandle hTerm);
  226. pascal short     TMSetConfig(TermHandle hTerm, const void *thePtr);
  227.  
  228. pascal OSErr     TMIntlToEnglish(TermHandle hTerm, const void *inputPtr, Ptr *outputPtr, short language);
  229. pascal OSErr     TMEnglishToIntl(TermHandle hTerm, const void *inputPtr, Ptr *outputPtr, short language);
  230.  
  231. pascal void     TMGetToolName(short id, Str255 name);
  232. pascal short     TMGetProcID(ConstStr255Param name);
  233.  
  234. pascal void     TMSetRefCon(TermHandle hTerm, long refCon);
  235. pascal long     TMGetRefCon(TermHandle hTerm);
  236.  
  237. pascal void     TMSetUserData(TermHandle hTerm, long userData);
  238. pascal long     TMGetUserData(TermHandle hTerm);
  239.  
  240. pascal short     TMAddSearch(TermHandle hTerm, ConstStr255Param theString, const Rect *where, 
  241.                             TMSearchTypes searchType, ProcPtr callBack);
  242. pascal void     TMRemoveSearch(TermHandle hTerm, short refnum);
  243. pascal void     TMClearSearch(TermHandle hTerm);
  244.  
  245. pascal Point     TMGetCursor(TermHandle hTerm, TMCursorTypes cursType);
  246.  
  247. pascal TMErr     TMGetTermEnvirons(TermHandle hTerm, TermEnvironRec *theEnvirons);
  248.  
  249. pascal short     TMChoose(TermHandle *hTerm, Point where, ProcPtr idleProc);
  250. pascal short     TMPChoose(TermHandle *hTerm, Point where, TMChooseRec *cRec);
  251. pascal void     TMEvent(TermHandle hTerm, const EventRecord *theEvent);
  252.  
  253. pascal Boolean     TMDoTermKey(TermHandle hTerm, ConstStr255Param theKey);
  254. pascal short     TMCountTermKeys(TermHandle hTerm);
  255. pascal void     TMGetIndTermKey(TermHandle hTerm, short id, Str255 theKey);
  256.  
  257. pascal void        TMGetErrorString(TermHandle hTerm, short id, Str255 errMsg);
  258.  
  259. #ifdef __cplusplus
  260. }
  261. #endif
  262.  
  263. #endif __TERMINALS__
  264.